inspector: Show the source of settings
authorMatthias Clasen <mclasen@redhat.com>
Fri, 19 Sep 2014 12:44:21 +0000 (08:44 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Mon, 22 Sep 2014 23:40:49 +0000 (19:40 -0400)
This can be useful at times to see if a setting is coming
from an XSetting, or overridden by the application.

https://bugzilla.gnome.org/show_bug.cgi?id=736971

gtk/inspector/prop-editor.c

index 103434dcadb2bf725dd88dbe778adf6416f8c215..607297524f4d9f48b858ad140515122c1e9aa365 100644 (file)
@@ -38,6 +38,7 @@
 #include "gtkradiobutton.h"
 #include "gtkscrolledwindow.h"
 #include "gtkspinbutton.h"
+#include "gtksettingsprivate.h"
 #include "gtktogglebutton.h"
 #include "gtkwidgetprivate.h"
 
@@ -1535,6 +1536,48 @@ add_settings_info (GtkInspectorPropEditor *editor)
   gtk_container_add (GTK_CONTAINER (editor), row);
 }
 
+static void
+add_gtk_settings_info (GtkInspectorPropEditor *editor)
+{
+  GObject *object;
+  const gchar *name;
+  GtkWidget *row;
+  GtkWidget *label;
+  const gchar *source;
+
+  object = editor->priv->object;
+  name = editor->priv->name;
+
+  if (!GTK_IS_SETTINGS (object))
+    return;
+
+  row = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 10);
+  gtk_container_add (GTK_CONTAINER (row), gtk_label_new (_("Source:")));
+
+  switch (_gtk_settings_get_setting_source (GTK_SETTINGS (object), name))
+    {
+    case GTK_SETTINGS_SOURCE_DEFAULT:
+      source = _("Default");
+      break;
+    case GTK_SETTINGS_SOURCE_THEME:
+      source = _("Theme");
+      break;
+    case GTK_SETTINGS_SOURCE_XSETTING:
+      source = _("XSettings");
+      break;
+    case GTK_SETTINGS_SOURCE_APPLICATION:
+      source = _("Application");
+      break;
+    default:
+      source = _("Unknown");
+      break;
+    }
+  gtk_container_add (GTK_CONTAINER (row), gtk_label_new (source));
+
+  gtk_widget_show_all (row);
+  gtk_container_add (GTK_CONTAINER (editor), row);
+}
+
 static void
 constructed (GObject *object)
 {
@@ -1570,6 +1613,7 @@ constructed (GObject *object)
 
   add_binding_info (editor);
   add_settings_info (editor);
+  add_gtk_settings_info (editor);
 }
 
 static void